<template>
  <div class="app-container">
    <el-dialog :title="'订单审核'+'（'+form.orderNo+'）'" :visible.sync="dialogVisible" width="30%" append-to-body>
      <el-form ref="form" :model="form">
        <el-form-item label="审核结果" prop="result" required>
          <el-select v-model="form.result" filterable style="width: 100%">
            <el-option
              v-for="item in dict.type.sys_approve_result"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核意见" prop="remark" :required="form.result==1">
          <el-input type="textarea" v-model="form.remark" placeholder="请输入"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible=false">取 消</el-button>
        <el-button type="primary" @click="dialogOk">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

import {noPayOrder, okPayOrder} from "../../../../api/payMng";

export default {
  dicts:['sys_approve_result'],
  data() {
    return {
      loading: false,
      dialogVisible: false,
      form: {}
    }
  },
  methods: {
    show(form) {
      this.dialogVisible = true
      this.form = {}
      this.resetForm('form')
      this.form.id = form.id
      this.form.orderNo = form.orderNo
    },
    dialogOk() {
      this.$refs.form.validate(e => {
        if (e) {
          if (this.form.result == 0) {
            okPayOrder(this.form).then(res => {
              this.$emit('ok')
              this.dialogVisible = false
              this.$message.success('审核成功')
            })
          }
          if (this.form.result == 1) {
            noPayOrder(this.form).then(res => {
              this.$emit('ok')
              this.dialogVisible = false
              this.$message.success('审核成功')
            })
          }
        }
      })
    },
  }
}
</script>
